Checking if an object has a property and accessing it